{extend name="common/__base"}

{block name="title"}{/block}

{block name="css"}{/block}

{block name="body"}
<form class="layui-form layui-form-pane">
    <input type="hidden" name="id" value="{$systemInfo.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">网站名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="web_name" value="{$systemInfo.web_name}" lay-verify="required" placeholder="网站名称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">网站版权</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="copyright" value="{$systemInfo.copyright}" lay-verify="required" placeholder="网站版权">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">LOGO</label>
        <div class="layui-input-block">
            <input type="hidden" id="logo" name="logo" value="{$systemInfo.logo}" lay-verify="required">
            <img src="{$systemInfo.logo}" id="logo_img" style="max-height: 100px;" alt="logo">
            <button class="layui-btn layui-btn-normal" type="button" id="upload_img">选择LOGO</button>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="submit">设置</button>
        </div>
    </div>
</form>
{/block}

{block name="js"}
<script>
    layui.use(['upload', 'form', 'jquery'], function () {
        let $ = layui.jquery;
        // 上传图片
        layui.upload.render({
            elem: "#upload_img",
            url: "{:url('tool/tool/uploadImg')}",
            done: function (res) {
                if (res.code == 1) {
                    $("#logo").val(res.data.url);
                    $("#logo_img").attr("src", res.data.url);
                }
            }
        });

        // 提交
        layui.form.on("submit(submit)", function (obj) {
            $.post("{:url('admin/system/systemInfo')}", $("form").serialize(), function (res) {
                layer.msg(res.msg);
            }, 'json');
            return false;
        });
    });
</script>
{/block}